﻿using System;

namespace RexToy.UI.Controls
{
    public class Block : Container
    {
        public override Palette Palette
        {
            get
            {
                return this.__palette;
            }
            set
            {
                var template = "ui-body-{0}";
                this.__domNode.ReplaceClass(StringExt.Format(template, this.__palette), StringExt.Format(template, value));
                this.__palette = value;
            }
        }

        public Block()
        {
            this.__palette = Palette.C;
            this.__domNode = RexToy.UI.Controls.DomNode.Create(new DomNodeCreateOptions()
            {
                tag = Tag.Div,
                hashName = "container",
                className = "ui-body ui-body-c"
            });
        }

        public void AppendText(string txt, Tag? tag)
        {
            var dom = RexToy.UI.Controls.DomNode.Create(new DomNodeCreateOptions()
            {
                tag = tag ?? Tag.Div,
                innerHTML = txt
            });

            this.__domNode.AppendChild(dom);
        }
    }
}
